<style>
.label-default {
    background-color: #f5f7fb;
	color: #999;
}
</style>
<div class="fui-page" ng-if="pagedata.op == 'main'">
	<div id="tab" class="fui-tab fui-tab-danger" style="top:0">
        <a class="external {{pagedata.params.status == 0?'active':''}}" href="javascript:" ng-click="pagedata.params.status=0;tool.get_list('jy_aihire/gong/list/',true)">待签</a>
        <a class="external {{pagedata.params.status == 1?'active':''}}" href="javascript:" ng-click="pagedata.params.status=1;tool.get_list('jy_aihire/gong/list/',true)">待入职</a>
        <a class="external {{pagedata.params.status == 2?'active':''}}" href="javascript:" ng-click="pagedata.params.status=2;tool.get_list('jy_aihire/gong/list/',true)">进行中</a>
        <a class="external {{pagedata.params.status == 3?'active':''}}" href="javascript:" ng-click="pagedata.params.status=3;tool.get_list('jy_aihire/gong/list/',true)">已完成</a>
    </div>
	<div class='fui-content'>
	<div class='jy-content'>
	<div class="fui-cell-group radius" ng-repeat="item in pagedata.list">
		<div class="fui-cellone" style="background:#fff;padding:0.5rem">
				<div class="fui-cellone-label"style="width:auto;padding-right:1rem;font-size:0.8rem">
					{{item.typetitle}}~{{item.paytypetitle}}
				</div>
				<div class="fui-cellone-info" style="text-align:right"></div>
				<div class="fui-cellone-remark">
					{{item.statustitle}}
				 </div>
		</div>
		<div class="fui-cell" style="background:#fff;padding:0.5rem;align-items:stretch">
				<div class="fui-cell-text" style="line-height:1.8">
					<div>{{item.jobinfo.title}}</div>
					<div>
						<span ng-if="item.day" class="label label-default">{{item.day}}入职</span>
						<span class="label label-default">{{item.onlinetime.start}}~{{item.onlinetime.end}}</span>
						<span class="label label-default">{{item.baotypetitle}}</span>
					</div>
					<div class="gray" style="font-size:0.65rem">
						{{item.merchname}} <span class="syscolor" ng-if="item.city">{{item.city}}</span>
					</div>
					<div>
						<span ng-if="item.isxieyiuser == 1" class="label label-info">已签协议</span>
						<span ng-if="item.ishetonguser == 1" class="label label-info">已签合同</span>
					</div>
				</div>
				<div class="fui-cellone-remark noremark">
					<span class="bold syscolor" style="font-size:0.9rem">{{item.jobinfo.pay}}</span>
				 </div>
		</div>
		<div ng-show="item.status == 2" class="fui-cell" style="background:#fff;padding:0.5rem;padding-top:0;">
				<div class="fui-cell-text" style="line-height:1.8">
					<div><i class="icon icon-phone" style="font-size:0.65rem" href="tel:{{item.merch.mobile}}">企业电话：{{item.merch.mobile}}</i></div>
					<div class="gray" style="font-size:0.65rem">
						最近打卡时间：{{item.signlog.starttime2||item.signlog.endtime2}}
					</div>
					<div class="gray" style="font-size:0.65rem">
						最近打卡地：{{item.signlog.address}}
					</div>
					<div class="gray" style="font-size:0.65rem">
						最近轨迹地：{{item.maplog.address}}
					</div>
				</div>
				<div class="fui-cellone-remark noremark">
					<span ng-if="item.signlog.id" class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="access_json('/maplog//id='+item.signlog.id)">上岗上班</span>
				 </div>
		</div>
		<div class="r" style="padding:0.5rem">
			<span ng-show="item.isxieyiuser == 0" class="btn btn-sm btn-default-o order-finish" href="javascript:" ng-click="pagedata.toxieyi(item)">签协议</span>
			<span ng-show="item.ishetonguser == 0 && item.isxieyiuser == 1" class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="pagedata.tohetong(item)">签合同</span>
			<span ng-show="item.status == 2 && (!item.signlog.starttime || item.signlog.endtime>0)" class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="pagedata.startsign(item)">打卡上班</span>
			<span ng-show="item.status == 2 && item.signlog.starttime>0 && item.signlog.endtime==0" class="btn btn-sm btn-default-o order-finish" href="javascript:" ng-click="pagedata.endsign(item)">打卡下班</span>
		</div>
	</div>
	</div>
	<div class="content-empty" ng-show="!pagedata.list || pagedata.list.length == 0 ">
		  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">您暂时没有任务！</p>
	</div>
	<div ng-include="sys_html('common/_copyright',true)"></div>
	</div>
</div>
<div ng-if="pagedata.show_xieyi" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<i class="closed icon icon-cuowu" ng-click="pagedata.show_xieyi=false"></i>
			<div class="content-images" style="padding:0.5rem;height:20rem; overflow-y:scroll;">
					<div class="title bold" style="font-size:0.8rem">[预览]{{pagedata.xieyi.title || '客户协议'}} / <small>Read Ggree</small></div>
					<div class="text" style="padding-top:0.5rem;font-size:0.7rem" ng-bind-html="trust(pagedata.xieyi.content)">
					</div>
			</div>
			<div class="modal-footer">
				<div ng-click="pagedata.show_xieyi=false;post({},'/gong/postxieyi/gongid='+pagedata.nowitem.id+'&xieyiid='+pagedata.xieyi.id)" class="mod-check" style="width: 100%; margin: 0;">前往签署</div>
			</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.show_hetong" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<i class="closed icon icon-cuowu" ng-click="pagedata.show_hetong=false"></i>
			<div class="content-images" style="padding:0.5rem;height:20rem; overflow-y:scroll;">
					<div class="title bold" style="font-size:0.8rem">[预览]{{pagedata.hetong.title || '客户合同'}} / <small>Read Ggree</small></div>
					<div class="text" style="padding-top:0.5rem;font-size:0.7rem">
						<img ng-repeat="img in pagedata.hetong.images" style="width:100%" ng-src="{{tomedia(img)}}">
					</div>
			</div>
			<div class="modal-footer">
				<div ng-click="pagedata.show_hetong=false;post({},'/gong/posthetong/gongid='+pagedata.nowitem.id+'&hetongid='+pagedata.hetong.id)" class="mod-check" style="width: 100%; margin: 0;">前往签署</div>
			</div>
		</div>
	</div>
</div>
<div ng-include="sys_html('_footer')"></div>
<script>
scope.tool.get_list('jy_aihire/gong/list/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_aihire/gong/list/');
}
scope.pagedata.toxieyi=function(item){
	scope.get('/gong/getxieyi/gongid='+item.id,function(res){
		scope.pagedata.nowitem=item
		scope.pagedata.show_xieyi=true;
		scope.pagedata.xieyi=res.xieyi;
		scope.$evalAsync();
	});
}
scope.pagedata.tohetong=function(item){
	scope.get('/gong/gethetong/gongid='+item.id,function(res){
		scope.pagedata.nowitem=item
		scope.pagedata.show_hetong=true;
		scope.pagedata.hetong=res.hetong;
		scope.$evalAsync();
	});
}
scope.pagedata.startsign=function(item){
	scope.pagedata.nowitem=item;
	scope.confirm({
			'message':'确定已经到了指定上班位置，打卡上班？',
			'success':function(){
				window.scope.location(function(res){
					console.log(res)
					if(res.lat_lng){
						scope.pagedata.nowitem.pcd=res.addressComponents
						scope.pagedata.nowitem.address=res.address
						scope.pagedata.nowitem.lat_lng=res.lat_lng
						scope.post_json('/gong/startsign/gongid='+item.id,scope.pagedata.nowitem);
					}else{
						scope.message('定位失败，打卡不成功！','error');
					}
				});
			},
			'fail':function(){}
	});
}
scope.pagedata.endsign=function(item){
	scope.pagedata.nowitem=item;
	scope.confirm({
			'message':'确定打卡下班？',
			'success':function(){
				window.scope.location(function(res){
					console.log(res)
					if(res.lat_lng){
						scope.pagedata.nowitem.pcd=res.addressComponents
						scope.pagedata.nowitem.address=res.address
						scope.pagedata.nowitem.lat_lng=res.lat_lng
						scope.post_json('/gong/endsign/gongid='+item.id,scope.pagedata.nowitem);
					}else{
						scope.message('定位失败，打卡不成功！','error');
					}
				});
			},
			'fail':function(){}
	});
}
</script>